#导入蓝图模块
from flask import Blueprint,request,jsonify
from db import db1
import  json
#实例化
bp_course = Blueprint("course",__name__)

#接口
@bp_course.route('/departmentM',methods=['POST','GET'])

def departmentM():
    #添加部门
    if request.method == 'POST':
        #获取数据
        data = request.data
        if data:
            data = json.loads(data)
        else:
            data = request.form
        #构造sql语句
        sql = "insert into coupon values(0,'%s')"%(data['dname'])
        #pymysql
        db1.insert(sql)
        #返回结果
        return jsonify({"code":200})
    else:
        pass
#接口
# @bp_course.route('/')